package com.forum.controller;

import com.forum.common.Result;
import com.forum.dto.FollowListDto;
import com.forum.dto.FollowRequest;
import com.forum.service.FollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/follows")
public class FollowController {

    @Autowired
    private FollowService followService;

    /**
     * 请求示例：
     * {
     *   "followerId": 1,
     *   "followingId": 2
     * }
     */
    @PostMapping("/follow")
    public Result<String> follow(@RequestBody FollowRequest request) {
        return followService.follow(request);
    }

    /**
     * 请求示例（请求体方式或通过URL参数均可）：
     * {
     *   "followerId": 1,
     *   "followingId": 2
     * }
     */
    @DeleteMapping("/unfollow")
    public Result<String> unfollow(@RequestBody FollowRequest request) {
        return followService.unfollow(request);
    }

    /**
     * 查询关注列表接口
     */
    @GetMapping("/list")
    public Result<List<Integer>> getFollowList(@RequestParam("queryUserId") Integer queryUserId
                                                   ) {
        return followService.getFollowList(queryUserId);
    }
}
